<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
<script>
function controlla(ilform)
{
	elementi = ilform.getElementsByTagName('input');  
	for(i=0;i<elementi.length;i++)
	{
		if(elementi[i].type == "radio")
		{
			// controllo radio da implementare
		}else if(elementi[i].type == "hidden")
		{
			// controllo hidden da implementare
		}
		else
		{
			if(elementi[i].accept.indexOf("R") != -1)
			{
				if(elementi[i].value == "")
				{
					alert(elementi[i].alt + ' non può essere vuoto.');
					return false;
				}
			}
			if(elementi[i].accept.indexOf("E") != -1)
			{
				if(elementi[i].value.indexOf("@") < 2)
				{
					alert(elementi[i].alt + ' deve contenere un\'email.');
					return false;
				}
			}
			if(elementi[i].accept.indexOf("N") != -1)
			{
				if(isNaN(elementi[i].value))
				{
				alert(elementi[i].alt + ' deve contenere un numero.');
				return false;
				}
			}
		}
	}// fine ciclo
	
	element = ilform.getElementsByTagName('textarea');  
	for(i=0;i<element.length;i++)
	{
		alert('El'+i+"->"+element[i].title);
		st = element[i].title.indexOf("|")+1;
		tit = element[i].title.substr(st,element[i].title.length-2);
		if(element[i].title.indexOf("R|") != -1)
		{
			if(element[i].value == "")
			{
				alert(tit + ' non può essere vuoto.');
				return false;
			}
		}
	}
	
 	return true;
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="#" onsubmit="return controlla(this)">

	<p>
	  <textarea name="textarea" title="R|Il testo" ></textarea>
  </p>
	<p>
	  <!--select name="select" alt="Tendina" accept="R">
	  <option></option>
	  <option value="BENE">BENE</option>
      </select-->
    </p>
	<p>
	  <input name="radiobutton" type="radio" value="1" accepr="RN"/>
	  <input name="radiobutton" type="radio" value="2" accepr="RN"/>
	  <br />
	  <input type="text" name="primo" value="" alt="Primo campo" accept="RN"/>
	</p>
  <p>
    <label>
    <input type="submit" name="Pulsante"  value="Pulsante" />
    </label>
  </p>
</form>


<p>Try it:</p>

<p><script src="jquery.js" type="text/javascript"></script>
<script src="jquery.suggest.js" type="text/javascript"></script>
<script src="jquery.dimensions.js" type="text/javascript"></script>
</p>
<link href="jquery.suggest.css" rel="stylesheet" type="text/css">
<input autocomplete="off" size="30" style="position: absolute;" id="suggest">
<script type="text/javascript">         
jQuery.noConflict(); 
jQuery(function() {  jQuery("#suggest").suggest("search.php",{ onSelect: function() {alert("You selected: " + this.value)}}); });
</script>
<br>
jquery.suggest is my attempt at a jQuery autocompleter that functions much like <a href="http://www.google.com/webhp?complete=1&amp;hl=en">Google Suggest</a>.

</body>
</html>
